<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>lphasor</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="lpfreson.html" title="lpfreson" />
    <link rel="next" href="lpinterp.html" title="lpinterp" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">lphasor</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="lpfreson.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="lpinterp.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="lphasor"></a>
      <div class="titlepage"></div>
      <a id="IndexLphasor" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">lphasor</span>
        </h2>
        <p>lphasor — 
      Generates a table index for sample playback
          </p>
      </div>
      <div class="refsect1">
        <a id="idp121231216"></a>
        <h2>Description</h2>
        <p>
      This opcode can be used to generate table index for sample playback (e.g. <a class="link" href="tablexkt.html" title="tablexkt">tablexkt</a>).
    </p>
      </div>
      <div class="refsect1">
        <a id="idp121273328"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ares <span class="command"><strong>lphasor</strong></span> xtrns [, ilps] [, ilpe] [, imode] [, istrt] [, istor]</pre>
      </div>
      <div class="refsect1">
        <a id="idp121275600"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>ilps</em></span> -- loop start.
    </p>
        <p>
      <span class="emphasis"><em>ilpe</em></span> -- loop end (must be greater than <span class="emphasis"><em>ilps</em></span> to enable looping).  The default value of <span class="emphasis"><em>ilps</em></span> and <span class="emphasis"><em>ilpe</em></span> is zero.
    </p>
        <p>
      <span class="emphasis"><em>imode</em></span> (optional: default = 0) -- loop mode. Allowed values are:
      </p>
        <div class="itemizedlist">
          <ul class="itemizedlist" style="list-style-type: disc; ">
            <li class="listitem">
              <p><span class="emphasis"><em>0:</em></span> no loop</p>
            </li>
            <li class="listitem">
              <p><span class="emphasis"><em>1:</em></span> forward loop</p>
            </li>
            <li class="listitem">
              <p><span class="emphasis"><em>2:</em></span> backward loop</p>
            </li>
            <li class="listitem">
              <p><span class="emphasis"><em>3:</em></span> forward-backward loop</p>
            </li>
          </ul>
        </div>
        <p>
    </p>
        <p>
      <span class="emphasis"><em>istrt</em></span> (optional: default = 0) -- The initial output value (phase). It must be less than <span class="emphasis"><em>ilpe</em></span> if looping is enabled, but is allowed to be greater than <span class="emphasis"><em>ilps</em></span> (i.e. you can start playback in the middle of the loop).
    </p>
        <p>
      <span class="emphasis"><em>istor</em></span> (optional: default = 0) -- skip initialization if set to any non-zero value.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp121288208"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>ares</em></span> -- a raw table index in samples (same unit for loop points). Can be used as index with the table opcodes.
    </p>
        <p>
      <span class="emphasis"><em>xtrns</em></span> -- transpose factor, expressed as a playback ratio. <span class="emphasis"><em>ares</em></span> is incremented by this value, and wraps around loop points. For example, 1.5 means a fifth above, 0.75 means fourth below. It is not allowed to be negative.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp121291696"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the lphasor opcode. It uses the file <a class="ulink" href="examples/lphasor.csd" target="_top"><em class="citetitle">lphasor.csd</em></a>.

      </p>
        <div class="example">
          <a id="idp121293552"></a>
          <p class="title">
            <strong>Example 452. Example of the lphasor opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
<span class="comment">; Audio out   Audio in</span>
-odac           -iadc     <span class="comment">;;;RT audio I/O</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o lphashor.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>
<span class="comment">; Example by Jonathan Murphy Dec 2006</span>

  <span class="ohdr">sr</span>	    <span class="op">=</span>  44100
  <span class="ohdr">ksmps</span>	    <span class="op">=</span>  10
  <span class="ohdr">nchnls</span>    <span class="op">=</span>  1

    <span class="oblock">instr</span> 1

  ifn	    <span class="op">=</span>  1   <span class="comment">; table number</span>
  ilen	    <span class="op">=</span>  <span class="opc">nsamp</span>(ifn)    <span class="comment">; return actual number of samples in table</span>
  itrns	    <span class="op">=</span>  1   <span class="comment">; no transposition</span>
  ilps	    <span class="op">=</span>  0   <span class="comment">; loop starts at index 0</span>
  ilpe	    <span class="op">=</span>  ilen <span class="comment">; ends at value returned by nsamp above</span>
  imode	    <span class="op">=</span>  3    <span class="comment">; loop forwards &amp; backwards</span>
  istrt	    <span class="op">=</span>  10000  <span class="comment">; commence playback at index 10000 samples</span>
  <span class="comment">; lphasor provides index into f1 </span>
  alphs	    <span class="opc">lphasor</span>   itrns, ilps, ilpe, imode, istrt
  atab	    <span class="opc">tablei</span>    alphs, ifn
	    <span class="comment">; amplify signal</span>
  atab	    <span class="op">=</span>  atab <span class="op">*</span> 10000

	    <span class="opc">out</span>	      atab

    <span class="oblock">endin</span>

<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="stamnt">f</span> 1 0 262144 1 "beats.wav" 0 4 1
<span class="stamnt">i</span>1 0 60
<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp121297872"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: Istvan Varga</td>
          </tr>
          <tr>
            <td>January 2002</td>
          </tr>
          <tr>
            <td>Example by: Jonathan Murphy</td>
          </tr>
        </table>
        <p>
    </p>
        <p>New in version 4.18</p>
        <p>Updated April 2002 and November 2002 by Istvan Varga</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="lpfreson.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="lpinterp.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">lpfreson </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> lpinterp</td>
        </tr>
      </table>
    </div>
  </body>
</html>
